package com.zr.gdms.controller;

import java.io.IOException;
import java.io.PrintWriter;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import javax.servlet.http.HttpSession;

import com.zr.gdms.model.Application;
import com.zr.gdms.service.AppShowService;
import com.zr.gdms.serviceimpl.AppShowServiceImpl;

import net.sf.json.JSONArray;

public class TeacherAppControllerXRA extends HttpServlet {
  AppShowService apps = new AppShowServiceImpl();
	@Override
	protected void doGet(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		// TODO Auto-generated method stub
		doPost(req, resp);
	}
	@Override
	protected void doPost(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		req.setCharacterEncoding("UTF-8");
		resp.setCharacterEncoding("UTF-8");
	    HttpSession session  = req.getSession();
		Date now = new Date(); 
		SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy/MM/dd HH:mm:ss");
		String apptime = dateFormat.format( now ); 
		String apptype = "离职申请";
		String appcontent = req.getParameter("appcontent");
		String appstate = "审核中";
		int tid = (int) session.getAttribute("tid");	
		boolean flag = apps.insertApp(apptype, appcontent, apptime, appstate, tid);
		PrintWriter pw = resp.getWriter();
		if (flag) {
			pw.write("1");
			pw.flush();
			pw.close();
		} else {
			pw.write("0");
			pw.flush();
			pw.close();
           
		}
	}
}
